import graphene
from graphene_django.types import DjangoObjectType

from apps.plan.models import Plan, PlanCase


class PlanT(DjangoObjectType):
    class Meta:
        model = Plan


#  定义查询
class Query(graphene.ObjectType):
    all_projects = graphene.List(PlanT)

    @graphene.resolve_only_args
    def resolve_all_projects(self, project_id, **kwargs):
        if project_id:
            return Plan.objects.all(project_id=project_id)
        else:
            return Plan.objects.all()


schema = graphene.Schema(query=Query)
